<%// Copyright 2008 Carnegie Mellon University
// Licensed under the Apache License, Version 2.0 (the "License"); 
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//  
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, 
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.%>

<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page pageEncoding="UTF-8" %>
<%@ page import="java.sql.*,java.util.*"%>
<%@ page import="edu.cmu.lti.sepia.data.db.*"%>
<%@ page import="edu.cmu.lti.sepia.data.resource.ResourceManager"%>
<%@ page import="edu.cmu.lti.sepia.api.html.UserStatGenerator"%>
<%@ page import="edu.cmu.lti.sepia.infra.topic.model.Task"%>
<%@ page import="edu.cmu.lti.sepia.servlet.Commons"%>

<%
out.println( Commons.getHeader(request, response, "User Statistics", 1) );

StringBuilder sb = new StringBuilder();
try {
	SQL sql = new SQL();
	List<Task> tasks = TaskDAO.getTasks(sql);
	if (tasks.size()>0) {
		for ( Task task : tasks ) {
			sb.append( UserStatGenerator.printTable( sql, task ) );
			sb.append( "<br><br>" );
		}
	} else {
	  sb.append("<strong>No statistics available yet.</strong>");
	}
    sb.append( "<br><br>" );
	sql.close();
} catch ( SQLException e ) {
	e.printStackTrace();
}
out.println(sb);
%>

<%
out.println( Commons.getFooter(request, response) );
%>
